home *** CD-ROM | disk | FTP | other *** search
- NAME
-
- Clac - a simple command line arithmetic calculator
-
-
- SYNOPSIS
-
- clac [-options] [@filename | expression]
-
-
- DESCRIPTION
-
- Clac calculates expressions following precedence (order of
- operations). Functions, variables and mode identifiers are
- case-insensitive for the user's convenience.
-
- Clac has three modes of operation:
- - An expression is parsed from arguments.
- - Without a filename or expression Clac enters
- interactive mode. Expressions are evaluated as
- they are entered.
- - Expressions are read from a file.
-
- If file named 'cli.ini' exists in the current directory, it's
- executed before anything else is done.
-
- The parser catches common mistakes like unmatched parenthesis or
- divide by zero and gives an (hopefully helpful) error message.
- Unrecognized characters produce also an error message.
-
- You can exit from interactive mode by giving Clac an empty line.
-
-
- OPTIONS
-
- command line options recognized by Clac.
-
- -d Output result in decimals. Default.
-
- -b Output result in binary.
- -o Output result in octal decimals.
- -h Output result in hex decimals.
- -r Trigonometric arguments as radians. Default.
- -g Trigonometric arguments as degrees.
- -c Complex numbers are output as real and imaginary
- components 'a + bi'. Default.
- -v Complex numbers are output as vectors '(x, y)'.
- -p Complex numbers are output in polar co-ordinates
- '(magnitude, direction)'. Trigonometric mode
- defines whether the direction is in degreees or
- radians.
- -q Quiet mode. Output only results.
-
-
- SYNTAX: CHARACTERS AND OPERATORS
-
- Clac recognizes the following characters and operators:
-
- <Enter> Evaluate expression or exit if none entered.
- |, & Bitwise OR and AND operators.
- >, < Operators for shifting bits right and left.
- +, - Addition and subtraction operators.
- % Modulo operator.
- *, / Multiply and divide operators.
- ^ Exponentiation operator.
- +, - Signs. Signed numbers should be in parenthesis.
- ( and ) Parenthesis.
- . Decimal point.
- = Assignment operator. Eg. 'test = 3.5'.
- : Mode (look at options) change character. Eg. ':b'.
- Zi Value Z is an imaginary number (1 + 2i).
- Z! value Z is a factor (3! = 1*2*3).
- 'Z Value Z is in binary format.
- #Z Value Z is in octal format.
- $Z, 0xZ Value Z is in hexadecimal format.
- "Z Value Z is in ascii format. Notice: Value is
- ended with a ' '.
- E Variable containing value of Napier's constant.
- PI Variable containing value of pi.
- ? Gives a brief overview of the operators and
- functions that Clac supports at the moment and
- lists all the defined variables and their
- values.
-
-
- Decimal numbers can have exponent notation (ie. a number
- immediatly followed by 'e' and a number). Eg. 1e2 = 1 * 10^2
- and 5e-1 = 5 * 10^(-1) = 0.5. Exponent has to be an integer.
-
- You can change the values of all variables including e and pi
- (if you're one of those people that insist on pi being 3).
-
- Variable names may contain only letters and numbers. Variable
- names have to start with a letter.
-
-
- SYNTAX: UNUSED CHARACTERS
-
- Characters, that are NOT used by Clac's expression evaluation:
- ':', '@', '[', ']', '\', '_', '`', '{', '}' and '~'.
-
-
- SYNTAX: FUNCTIONS WITH SINGLE ARGUMENT
-
- ln(x) Natural logarithm of x.
- lg(x) Logarithm of x in base 10.
- deg(x) Convert x radians to degrees.
- rad(x) Convert x degrees to radians.
- sin(x) Sine of x.
- cos(x) Cosine of x.
- tan(x) Tangent of x.
- asin(x) Arcus sine of x.
- acos(x) Arcus cosine of x.
- atan(x) Arcus tangent of x.
- sinh(x) Hyperbolic sine of x.
- cosh(x) Hyperbolic cosine of x.
- tanh(x) Hyperbolic tangent of x.
- sqrt(x) Square root of x.
- rnd(x) Random number between 0 and x.
- abs(x) Absolute of x.
- int(x) Integer part of x.
- frac(x) Fraction part of x.
- real(x) Real part of x.
- imag(x) Imaginary part of x.
-
-
- SYNTAX: FUNCTIONS WITH MULTIPLE ARGUMENTS
-
- rtop(a, b) Rectangular co-ordinate a (if complex)
- or co-ordinate pair (a, b) (if two reals)
- is converted to polar one.
- ptor(a, b) Polar co-ordinate a (if complex vector)
- or co-ordinate pair (a, b) (if two reals)
- is converted to rectangular one.
- over(n, k) The number of k component group combinations
- in n components.
- root(n, x) Nth root of x.
- time(h, m, s) Change time into seconds.
- min(a, b, c) Smallest number of a, b, c.
- max(a, b, c) Largest number of a, b, c.
- avg(a, b, c) Average of numbers a, b, c.
- std(a, b, c) Standard deviation of numbers a, b, c.
-
- Number of arguments is unlimited in the min(), max(), avg() and
- std() functions.
-
-
- EXAMPLES
-
- From a command line:
- clac '42 + $FF.8 - (("ET * 12) + 5) / 3.7 + (-1)'
-
- Interactively:
- clac -g -b
-
- Expression: foo = sin(90)
- %1
- Expression: foo + 12
- %1101
-
- Expression: a = 1 + 2i
- 1.0 + 2.0i
- Expression: b = 2 + 1i
- 2.0 + 1.0i
- Expression: a / b
- 0.8 + 0.6i
-
-
- PROGRAM STRUCTURE
-
- Clac is composed of two nearly separate 'modules':
-
- - 'clac.c', which evaluates expressions.
-
- - 'cli.c', which gets expressions from the user, command line
- arguments or from a file. It also takes care of the variable
- assignments and the help function.
-
- Communication between these to parts is done with a exp_packet
- structure which is better documented on the 'clac.h' file.
-
- For more info see 'clac.dvi' and 'cli.dvi' files.
-
-
- LIMITATIONS
-
- 255 character limit for expressions (do you need more?).
-
- Values are internally calculated using double precision numbers.
-
- No overflow check.
-
-
- ADVANTAGES
-
- Uses little memory because evaluating is done in the sync with
- the parsering.
-
- IMO easy to use and add new functions (to 'function.h' and
- function.c).
-
-
- BUGS
-
- Sure. Before I sent this I had fixed all errors that I had
- found. Please report any bugs that you'll happen to found
- (especially the 'logical' ones).
-
-
- THANKS TO
-
- - Jarkko Kniivil"a, who advised me on C syntax.
- - Gernot Saltzer for bugreports and suggestions.
- - J"urgen Lock, who patiently answered to my mail.
- - Helpful people on #atari (irc), whom I have
- chatted with: Dirch, Gryf, Infy, Aviva...
-
-
- COPYRIGHT
-
- Eero Tamminen / puujalka (irc), t150315@cc.tut.fi.
-
- Freeware. This code may be used freely in other freeware
- programs on condition that my effort has been mentioned
- on the program documentation. I would also like to get
- a copy of the program which incorporates my code...
-
-
- CHECK ALSO
-
- Sketches of Spain (Miles Davis).
-
-
-
- v 1.10 Release: 10th November 1994 CLAC(1)
-
-